import userpermissionList from "@/store/PermissionList"
export const regPermission = (app) => {
  // console.log(app)
  app.directive("permissionAdd", {
    // 某个生命周期里面,判断 当前 userStore 里面是否有 传入的 value
    mounted(el, binding) {
      const aaa = userpermissionList()
      // console.log(aaa.screenQuanxianList, "当前筛选出来的权限的数据")
      // console.log(binding.value.path, "当前路由")
      // console.log(aaa.cerrentAdmin.roleId)
      const res = aaa.screenQuanxianList
        .find((item) => item.path == binding.value.path)
        .edit.add.includes(aaa.cerrentAdmin.roleId)
      console.log(res, "筛选出来的数据(添加)")
      if (res) {
        el.style.display = "block"
      } else {
        el.style.display = "none"
      }
    }
  })

  app.directive("permissionUpdate", {
    // 某个生命周期里面,判断 当前 userStore 里面是否有 传入的 value
    mounted(el, binding) {
      const aaa = userpermissionList()
      // console.log(aaa.screenQuanxianList, "当前筛选出来的权限的数据")
      // console.log(binding.value.path, "当前路由")
      // console.log(aaa.cerrentAdmin.roleId)
      const res = aaa.screenQuanxianList
        .find((item) => item.path == binding.value.path)
        .edit.update.includes(aaa.cerrentAdmin.roleId)
      console.log(res, "筛选出来的数据(更改)")
      if (res) {
        el.style.display = "block"
      } else {
        el.style.display = "none"
      }
    }
  })
  app.directive("permissionDel", {
    // 某个生命周期里面,判断 当前 userStore 里面是否有 传入的 value
    mounted(el, binding) {
      const aaa = userpermissionList()
      // console.log(aaa.screenQuanxianList, "当前筛选出来的权限的数据")
      // console.log(binding.value.path, "当前路由")
      // console.log(aaa.cerrentAdmin.roleId)
      const res = aaa.screenQuanxianList
        .find((item) => item.path == binding.value.path)
        .edit.del.includes(aaa.cerrentAdmin.roleId)
      console.log(res, "筛选出来的数据(删除)")
      if (res) {
        el.style.display = "black"
      } else {
        el.style.display = "none"
      }
    }
  })
}
